package com.atguigu.nio;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NioFileChannel02 {
    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream=new FileInputStream("e:\\file01.txt");
        FileChannel channel = fileInputStream.getChannel();
        ByteBuffer byteBuffer=ByteBuffer.allocate(1024);
        //将通道数据读入到buffer中
        channel.read(byteBuffer);
        //将byteBuffer转换为字符串
        System.out.println(new String(byteBuffer.array()));
        fileInputStream.close();
    }
}
